<template>
  <div>
    <div>
      <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
        :dataSource="dataSource" :pagination="ipagination" :loading="loading" class="j-table-force-nowrap"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">详情</a>
          <!-- <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" style="color: rgb(224, 118, 118);" @confirm="() => handleDelete(record.id)">
              <a v-has="'user:logdelete'">删除</a>
            </a-popconfirm> -->
        </span>
        <!-- 主要代码在这里 -- 下面这些 -->
        <span slot="bzbz" slot-scope="text, record">
          <a-tooltip placement="top">
            <template slot="title">
              <span>{{ text }}</span>
            </template>
            <span class="ellipsis">{{ text }}</span>
          </a-tooltip>
        </span>
      </a-table>
    </div>
    <tiger-device-log-modal ref="modalForm" @ok="modalFormOk"></tiger-device-log-modal>
  </div>
</template>
  
<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import TigerDeviceLogModal from './modules/TigerDeviceLogModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import store from '@/store/'

export default {
  name: 'TigerDeviceWarningTable',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    TigerDeviceLogModal
  },
  props:{
    orgCode:{
      type:String,
      default:store.getters.userInfo.orgCode
    },
    logCate:{
      type:String,
      default:"1"
    },
  },
  data() {
    return {
      description: '设备日志管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'name',
        },
        // {
        //   title: '所属机构',
        //   align: "center",
        //   dataIndex: 'sysOrgCode',
        // },
        {
          title: '日志时间',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '日志内容',
          align: "center",
          dataIndex: 'content',
          width: 197,
          scopedSlots: { customRender: 'bzbz' },
        },
        // {
        //   title: '日志类别',
        //   align: "center",
        //   dataIndex: 'logCategory_dictText',
        // },
        {
          title: '预警类型',
          align: "center",
          dataIndex: 'logType_dictText'
        },
        {
          title: '处理状态',
          align: "center",
          dataIndex: 'handleStatus_dictText'
        },
        {
          title: '处理内容',
          align: "center",
          dataIndex: 'handleContent',
          width: 197,
          scopedSlots: { customRender: 'bzbz' },
        },
        {
          title: '处理人',
          align: "center",
          dataIndex: 'updateBy'
        },
        // {
        //   title: '处理日期',
        //   align: "center",
        //   dataIndex: 'updateTime'
        // },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/tiger/tigerDeviceLog/list",
        delete: "/tiger/tigerDeviceLog/delete",
        deleteBatch: "/tiger/tigerDeviceLog/deleteBatch",
        exportXlsUrl: "/tiger/tigerDeviceLog/exportXls",
        importExcelUrl: "tiger/tigerDeviceLog/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
      loadPause: true
    }
  },
  created() {
    this.getSuperFieldList();
  },
  mounted() {
      this.tableRefresh();
  },
  watch: {
    orgCode(val) {
      this.queryParam.sysOrgCode = "*" + this.orgCode + "*";
      this.searchQuery();
    },
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig() {
    },
    
    tableRefresh(){
      this.loadPause = false
      this.queryParam.sysOrgCode = "*" + this.orgCode + "*";
      this.queryParam.logCategory = this.logCate;
      this.searchQuery();
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'updateBy', text: '更新人', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'updateTime', text: '更新日期' })
      fieldList.push({ type: 'string', value: 'sysOrgCode', text: '所属部门', dictCode: '' })
      fieldList.push({ type: 'string', value: 'name', text: '设备名称', dictCode: '' })
      fieldList.push({ type: 'datetime', value: 'createTime', text: '日志时间' })
      fieldList.push({ type: 'string', value: 'content', text: '日志内容', dictCode: '' })
      fieldList.push({ type: 'string', value: 'logCategory', text: '日志类别', dictCode: 'device_log_category' })
      fieldList.push({ type: 'string', value: 'logType', text: '操作类型', dictCode: 'device_log_type' })
      fieldList.push({ type: 'string', value: 'handleStatus', text: '处理状态', dictCode: 'log_handle_type' })
      fieldList.push({ type: 'string', value: 'handleContent', text: ' 处理内容', dictCode: '' })
      fieldList.push({ type: 'string', value: 'updateBy', text: ' 处理人', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';

.ellipsis {
  display: block;
  width: 200px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
</style>